#ifndef SCHEDULEWIDGET_H
#define SCHEDULEWIDGET_H

#include <QWidget>
#include <QTableWidget>
#include <QMap>
#include <QVector>
#include <QPair>
#include <QStringList>

class QTableWidget;
class QPushButton;
class QComboBox;
class QLabel;
class QTableWidgetItem;

class ScheduleWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ScheduleWidget(QWidget *parent = nullptr);

private:
    void layoutInit(void);
    int customWeekNumber(const QDate &date) const;
    //获取当前周的日期范围
    QPair<QDate, QDate> getWeekRange(int year, int week) const;
    //加载课程表
    void loadSchedule(void);

private slots:
    //添加课程
    void addCourse(void);
    void deleteCourse(void);
    void handleItemChanged(QTableWidgetItem *item);

private:
    //UI变量
    QComboBox *m_comboBoxYear;
    QComboBox *m_comboBoxWeek;
    QLabel *m_labelDateRange;
    //课程表
    QTableWidget *m_tableWidget;
    //按钮
    QPushButton *m_pushButtonPrevWeek;
    QPushButton *m_pushButtonNextWeek;
    QPushButton *m_pushButtonAdd;
    QPushButton *m_pushButtonDel;

    //数据变量
    QMap<QPair<int, int>, QVector<QVector<QString>>> m_scheduleData;  //存储课程表数据
    QStringList m_times;
};

#endif // !SCHEDULEWIDGET_H
